package user;

import operation.*;

import java.util.Scanner;

public class AdminUser extends User{

    public AdminUser(String username) {
        super(username);
        this.operations = new IOperation[]{
                new ExitOperation(),
                new AddOperation(),
                new DelOperation(),
                new UpdateOperation(),
                new ShowOperation(),
                new SearchOperation()
        };
    }

    @Override
    public int menu() {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            System.out.println("请输入操作的类型: ");
            System.out.println("****************************");
            System.out.println("*********0.退出程序**********");
            System.out.println("*********1.增加图书**********");
            System.out.println("*********2.删除图书**********");
            System.out.println("*********3.修改图书**********");
            System.out.println("*********4.显示全部**********");
            System.out.println("*********5.查找图书**********");
            System.out.println("****************************");

            int choice = scanner.nextInt();
            if(choice <= operations.length) {
                return choice;
            } else {
                System.out.println("输入错误,请重新输入!");
            }
        }
    }
}
